<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang exam.index_option.view.header}</h3>
				</div>
				<div class="widget-content">
					<form action="{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&nextquery={$_var[gp_nextquery]}" class="form-search" id="frm_search" name="frmSearch" method="post">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_submit" class="btn btn-small btn-primary" {$dispatches[operations][edit]}>{lang admin.operation.submit}</a>
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]} >{lang admin.operation.delete}</a>
							<a href="{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&do=pub&nextquery={$_var[gp_nextquery]}" class="btn btn-small" {$dispatches[operations][add]}>{lang exam.index_option.view.operation.add}</a>
							<a href="{$ADMIN_SCRIPT}/exam{$search[prevquery]}" class="btn btn-small">{lang exam.index_option.view.operation.back}</a>
						</div>
						<div class="pull-right" {$dispatches[operations][search]}>
							<div class="input-append" >
								<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small search-query" maxlength="20"/>
								<button type="submit" class="btn">{lang admin.search.submit}</button>
							</div>
							<button type="button" state="0" class="btn" id="btn_extend_search">{lang admin.search.submit.extend}<i class="micon-arrow-down"></i></button>
						</div>
					</div>
					</form>
					
					<div id="div_extend_search" style="display:none;">
						<hr/>
						<form id="frm_extend_search" name="frmExtendSearch" action="{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&nextquery={$_var[gp_nextquery]}" method="post">
						<input type="hidden" name="hdnSearchShow" id="hdnSearchShow" value="1" />
						<table>
						<tr>
							<td width="46">{lang admin.search.keyword}</td>
							<td>
								<label class="checkbox inline">
									<input type="text" name="txtKeyword" value="{$_var[gp_txtKeyword]}" class="input-small" maxlength="20" />
								</label>
								<label class="checkbox inline">
								<select name="sltType">
						            <option value="0" {if $_var['gp_sltType'] == 0}selected="selected"{/if}>{lang exam.index_option.view.search.keyword.select.0}</option>
						            <option value="1" {if $_var['gp_sltType'] == 1}selected="selected"{/if}>{lang exam.index_option.view.search.keyword.select.1}</option>
						            <option value="2" {if $_var['gp_sltType'] == 2}selected="selected"{/if}>{lang exam.index_option.view.search.keyword.select.2}</option>
						        </select>
						        </label>
								<!--{if count($exam_categories) > 0}-->
						        <label class="checkbox inline">
						        <select name="sltSCategoryID">
						            <option value="0">{lang exam.index_option.view.search.category.select.0}</option>
						            <!--{loop $exam_categories $loop $exam_category}-->
						            <option value="{$exam_category[EXAM_CATEGORYID]}" {if $_var['gp_sltSCategoryID'] == $exam_category['EXAM_CATEGORYID']}selected="selected"{/if}>{$exam_category[CNAME]}</option>
						            <!--{/loop}-->
						        </select>
						        </label>
						        <!--{/if}-->
						        <label class="checkbox inline">
						        <select name="sltReType">
						            <option value="0">{lang exam.index_option.view.search.retype.select.0}</option>
						            <option value="1" {if $_var['gp_sltReType'] == 1}selected="selected"{/if}>{lang exam.index_option.view.search.retype.select.1}</option>
						            <option value="2" {if $_var['gp_sltReType'] == 2}selected="selected"{/if}>{lang exam.index_option.view.search.retype.select.2}</option>
						            <option value="3" {if $_var['gp_sltReType'] == 3}selected="selected"{/if}>{lang exam.index_option.view.search.retype.select.3}</option>
						            <option value="4" {if $_var['gp_sltReType'] == 4}selected="selected"{/if}>{lang exam.index_option.view.search.retype.select.4}</option>
						        </select>
						        </label>
							</td>
						</tr>
						<tr>
							<td>{lang admin.search.time}</td>
							<td>
								<input type="text" name="txtBeginDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtBeginDate]}" />
					            {lang admin.search.to}
					            <input type="text" name="txtEndDate" maxlength="16" class="input-medium input-date" value="{$_var[gp_txtEndDate]}" />
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<button type="submit" class="btn btn-primary">{lang admin.search.submit.extend.submit}</button>
							</td>
						</tr>
						</table>
				    	</form>
					</div>
					
					<hr/>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&page={$_var[page]}&psize={$_var[psize]}&nextquery={$_var[gp_nextquery]}{$search[querystring]}" method="post">
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="20"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="60">{lang exam.index_option.view.th.no}</th>
					            <th>{lang exam.index_option.view.th.name}</th>
					            <th width="120">{lang exam.index_option.view.th.edit}</th>
					            <th width="80">{lang exam.index_option.view.th.retype}</th>
					            <th width="90">{lang exam.index_option.view.th.operate}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $exam_options $_loop $exam_option}-->
							<tr class="item-row">
								<td>
									<input type="checkbox" class="fancy"  name="cbxItem[]" value="{$exam_option[EXAM_OPTIONID]}" title="{$exam_option[TITLE]}"/>
	            				</td>
	            				<td>
					            	<input type="text" class="input-mini" name="displayorder[{$exam_option[EXAM_OPTIONID]}]" value="{$exam_option[DISPLAYORDER]}"/>
					            </td>
					            <td>
					            	<p class="text-success thin">
						            	<span class="text-info">
							            	<!--{if $exam_option['CNAME']}-->
							            	<strong>[{$exam_option[CNAME]}]</strong>
							            	<!--{/if}-->
						            	</span>
						            	{$exam_option[TITLE]}
					            	</p>
					            	
					            	<!--{loop $exam_option[ITEMS] $item}-->
									<p class="f12 thin {echo $item['ANSWER'] ? 'text-error' : '';}">
										{$item[DISPLAYORDER]}、
										<!--{if $item[TITLE]}-->
										&nbsp;{$item[TITLE]}
										<!--{/if}-->
										<!--{if $item[FILE01]}-->
										&nbsp;<img src="{$item[FILE01]}" width="35" style="width:35px; height:35px;" border="0"/>
										<!--{/if}-->
									</p>
									<!--{/loop}-->
					            </td>
					            <td class="f12">{$exam_option[USERNAME]}<br/>{$exam_option[EDITTIME]}</td>
					            <td class="f12">
					            	<!--{if $exam_option['RETYPE'] == 0}-->{lang exam.index_option.view.td.retype.0}
					            	<!--{elseif $exam_option['RETYPE'] == 1}-->{lang exam.index_option.view.td.retype.1}
					            	<!--{elseif $exam_option['RETYPE'] == 2}-->{lang exam.index_option.view.td.retype.2}
					            	<!--{elseif $exam_option['RETYPE'] == 3}-->{lang exam.index_option.view.td.retype.3}
					            	<!--{/if}-->
						        </td>
					            <td>
					            	<a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&do=update&optionid={$exam_option[EXAM_OPTIONID]}&page={$_var[page]}&psize={$_var[psize]}&nextquery={$_var[gp_nextquery]}{$search[querystring]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					                <a class="btn btn-mini btn-delete" title="{$exam_option[TITLE]}" data="{$exam_option[EXAM_OPTIONID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
				            	</td>
				            </tr>
							<!--{/loop}-->
							
							<!--{if $count == 0}-->
							<tr>
					            <td colspan="6">
					                * {lang admin.operation.empty}
					            </td>
					        </tr>
					        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>
function search_toggle(){
	var state = $('#btn_extend_search').attr('state');
	if(state == '0'){
		$('#btn_extend_search').html('{lang admin.search.submit.extend.hide}<i class="micon-arrow-up"></i>').attr('state', '1');
	}else{
		$('#btn_extend_search').html('{lang admin.search.submit.extend}<i class="micon-arrow-down"></i>').attr('state', '0');
	}
	
	$('.pull-right .input-append').toggle();
	$('#div_extend_search').toggle();
}

$(function(){
	$('.fancy').uniform();
	
	$('.input-date').datepicker({format:'yyyy-mm-dd'});
	
	$('#btn_submit').click(function(){
		$('#frm_grid').submit();
	});
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') +'； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang exam.index_option.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&do=delete_list&page={$_var[page]}&psize={$_var[psize]}&nextquery={$_var[gp_nextquery]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang exam.index_option.view.operation.empty}'});
	});
	
	$('#btn_extend_search').click(function(){
		search_toggle();
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var exam_optionid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('title') + '； </p>';
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang exam.index_option.view.operation.delete.one}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/exam/_option&id={$_var[gp_id]}&do=delete&optionid=' + exam_optionid + '&page={$_var[page]}&psize={$_var[psize]}&nextquery={$_var[gp_nextquery]}{$search[querystring]}');
				$('#frm_grid').submit();
			});
		}});
	});
	
	{if $_var[gp_hdnSearchShow]}
	search_toggle();
	{/if}
});
</script>
<!--{template /module/admin/view/foot}-->